package member.model.dao;

import java.sql.SQLException;
import java.util.ArrayList;

import member.model.domain.Member;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;


@Repository
public class MemberDAO {
	
	@Autowired
	private SqlMapClientTemplate sqlMap;
	public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMap){
		this.sqlMap = sqlMap;
	}
	
	public void insertMember(Member member) throws SQLException{
		sqlMap.insert("insertMember", member);
	}
	public int updateMember(Member member) throws SQLException{
		return sqlMap.update("updateMember", member);
	}
	
	public int deleteMemberById(String member_id) throws SQLException{
		return sqlMap.delete("deleteMemberById", member_id);
	}
	public Member selectMemberById(String member_id) throws SQLException{
		return (Member)sqlMap.queryForObject("selectMemberById", member_id);
	}
	
	public ArrayList<Member> selectMemberByEmail(String email) throws SQLException{
		return (ArrayList<Member>)sqlMap.queryForList("selectMemberByEmail", email);
	}
	public ArrayList<Member> selectAllMember() throws SQLException{
		return (ArrayList<Member>)sqlMap.queryForList("selectAllMember");
	}
	/*
	public Member selectMemberByIdJoinBook(String member_id) throws SQLException{
		return (Member)sqlMap.queryForObject("selectMemberByIdJoinBook", member_id);
	}
	public ArrayList<Member> selectAllMemberRentingBooks() throws SQLException{
		return (ArrayList<Member>)sqlMap.queryForList("selectAllMemberJoinBook");
	}
	*/
}
